

package net.qiqbframework.messaging.annotation;



import net.qiqbframework.messaging.Message;

import javax.annotation.Nonnull;

/**
 * This will implement {@link MessageHandlerInterceptorMemberChain} with no more interceptors. It can be used a default
 * interceptor, for example in the {@link AnnotatedHandlerInspector}.
 *
 * @param <T> the type of the handlers
 */
public class NoMoreInterceptors<T> implements MessageHandlerInterceptorMemberChain<T> {

    /**
     * Creates and returns a new instance
     *
     * @return a new {@link NoMoreInterceptors} instance
     * @param <T> the type of the handlers
     */
    public static <T> MessageHandlerInterceptorMemberChain<T> instance() {
        return new NoMoreInterceptors<>();
    }

    @Override
    public Object handle(@Nonnull Message<?> message, @Nonnull T target,
                         @Nonnull MessageExecutableHandler handler) throws Exception {
        return handler.handle(message, target);
    }
}
